/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.osbosoftware.vista.utils;

/**
 *
 * @author osbosoftware
 */

import java.io.IOException;
import java.util.Iterator;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;


public class Utilidades {

    public Utilidades() {
    }

    public UIComponent findComponent(UIComponent parent, String id) {
        if (id.equals(parent.getId())) {
            return parent;
        }
        Iterator<UIComponent> kids = parent.getFacetsAndChildren();
        while (kids.hasNext()) {
            UIComponent kid = kids.next();
            UIComponent found = findComponent(kid, id);
            if (found != null) {
                return found;
            }
        }
        return null;
    }

    public void redireccionPaginaInicio() throws IOException {
       redireccion("start.jsf");
    }
    public void redireccion(String esta) throws IOException {
       FacesContext.getCurrentInstance().getExternalContext().redirect(esta);
    }
}
